/**
  @(#)$Id: AL_Node.h 74 2013-10-10 12:42:07Z xiaoting $
  @brief	store data, and be used to AL_ListSingle, AL_ListDouble, AL_ListCircular and so on

  ////////////////////////////////Chain storage structure//////////////////////////////////////////
  The computer using a set of arbitrary linear table storage unit stores data elements (which may be a continuous plurality of memory 
  cells, it can be discontinuous).

  It does not require the logic elements of adjacent physical location is adjacent to and therefore it is not sequential storage 
  structure has a weakness, but also lost the sequence table can be accessed randomly advantages.

  Chain store structural features:
	1, compared with sequential storage density storage structure (each node consists of data fields and pointers domains, so the same 
	space is full, then assume full order of more than chain stores).
	2, the logic is not required on the adjacent node is physically adjacent.
	3, insert, delete and flexible (not the mobile node, change the node as long as the pointer).
	4, find the node when stored sequentially slower than the chain stores.
	5, each node is a pointer to the data fields and domains.

  @Author $Author: xiaoting $
  @Date $Date: 2013-10-10 20:42:07 +0800 (周四, 10 十月 2013) $
  @Revision $Revision: 74 $
  @URL $URL: https://svn.code.sf.net/p/xiaoting/game/trunk/MyProject/AL_DataStructure/groupinc/AL_Node.h $
  @Header $Header: https://svn.code.sf.net/p/xiaoting/game/trunk/MyProject/AL_DataStructure/groupinc/AL_Node.h 74 2013-10-10 12:42:07Z xiaoting $
 */

#ifndef CXX_AL_NODE_H
#define CXX_AL_NODE_H

#ifndef CXX_AL_FUNCTIUONAL_H
#include "AL_Functional.h"
#endif

///////////////////////////////////////////////////////////////////////////
//			AL_Node
///////////////////////////////////////////////////////////////////////////

template<typename T> class AL_ListSingle;
template<typename T> class AL_ListDouble;
template<typename T> class AL_ListCircularSingle;
template<typename T> class AL_ListCircularDouble;
template<typename T> class AL_StackList;
template<typename T> class AL_QueueList;


template<typename T> 
class AL_Node
{
friend class AL_ListSingle<T>;
friend class AL_ListDouble<T>;
friend class AL_ListCircularSingle<T>;
friend class AL_ListCircularDouble<T>;
friend class AL_StackList<T>;
friend class AL_QueueList<T>;
template<typename T, typename Compare> friend class AL_QueuePriorityList;

public:
	/**
	* Destruction
	*
	* @param
	* @return
	* @note
	* @attention 
	*/
	~AL_Node();

protected:
private:
	/**
	* Construction
	*
	* @param
	* @return
	* @note		private the Construction, avoid the others use it
	* @attention
	*/
	AL_Node();
	
	/**
	* Construction
	*
	* @param const T& tData <IN>
	* @return
	* @note
	* @attention private the Construction, avoid the others use it
	*/
	AL_Node(const T& tData);

	/**
	*Copy Construct
	*
	* @param const AL_Node<T>& cAL_Node
	* @return
	*/
	AL_Node(const AL_Node<T>& cAL_Node);

	/**
	*Assignment
	*
	* @param const AL_Node<T>& cAL_Node
	* @return AL_Node<T>&
	*/
	AL_Node<T>& operator = (const AL_Node<T>& cAL_Node);

public:
protected:
private:
	T m_tData;				//the friend class can use it directly
	AL_Node *m_pPre;			//previous data			AL_ListDouble will use it
	AL_Node *m_pNext;			//next data
};

///////////////////////////////////////////////////////////////////////////
//			AL_Node
///////////////////////////////////////////////////////////////////////////

/**
* Construction
*
* @param
* @return
* @note		private the Construction, avoid the others use it
* @attention
*/
template<typename T>
AL_Node<T>::AL_Node():
m_pPre(NULL),
m_pNext(NULL)
{
	//memset(&m_tData, 0x00, sizeof(T));		//can not use memset, as to pointer or virtural pointer of class
}

/**
* Construction
*
* @param const T& tData <IN>
* @return
* @note
* @attention private the Construction, avoid the others use it
*/
template<typename T>
AL_Node<T>::AL_Node(const T& tData):
m_tData(tData),
m_pPre(NULL),
m_pNext(NULL)
{

}


/**
* Destruction
*
* @param
* @return
* @note
* @attention 
*/
template<typename T>
AL_Node<T>::~AL_Node()
{
	//it doesn't matter to clear the pointer or not.
	m_pPre = NULL;
	m_pNext = NULL;
}

#endif // CXX_AL_NODE_H
/* EOF */
